﻿@model VVA.Website.UI.Models.ViewModel.ContactForm
@Scripts.Render("~/bundles/jqueryval")
<form>
    <div id="contact-form">
        <div class="contact-form-input">
            @Html.LabelFor(i => i.Name, new { @class = "xlInput" })
            @Html.TextBoxFor(i => i.Name, new { @class = "xLarge" })
        </div>
        <div class="contact-form-input">
            @Html.LabelFor(i => i.Company, new { @class = "xlInput" })
            @Html.TextBoxFor(i => i.Company, new { @class = "xLarge" })
        </div>
        <div class="contact-form-input">
            @Html.LabelFor(i => i.Email, new { @class = "xlInput" })
            @Html.TextBoxFor(i => i.Email, new { @class = "xLarge" })
            @Html.ValidationMessageFor(i => i.Email)
        </div>
        <div class="contact-form-input">
            @Html.LabelFor(i => i.Subject, new { @class = "xlInput" })
            @Html.TextBoxFor(i => i.Subject, new { @class = "xLarge" })
            @Html.ValidationMessageFor(i => i.Subject)
        </div>
        <div class="contact-form-input">
            @Html.LabelFor(i => i.Message, new { @class = "xlInput" })
            @Html.TextAreaFor(i => i.Message, new { @class = "xLarge", style="resize:none", rows = "10" })
            @Html.ValidationMessageFor(i => i.Message)
        </div>
        <div class="contact-form-input">
            <input type="button" id="btnSend" value="@HttpContext.GetGlobalResourceObject("Common", "Send")" style="float: left; width: 75px" />
            <input type="reset" style="float: right; width: 75px" />
            <div style="clear: both"></div>
        </div>
    </div>
</form>
<script type="text/javascript">
    $(document).ready(function () {
        $("form").validate();
    });

    $("#btnSend").live("click", function () {
        if ($("form").valid()) {
            var name = $("#Name").val();
            var company = $("#Company").val();
            var email = $("#Email").val();
            var subject = $("#Subject").val();
            var message = $("#Message").text();

            $.ajax({
                type: "POST",
                data: {
                    name: name,
                    company: company,
                    email: email,
                    subject: subject,
                    message: message
                },
                url: "@Url.Action("Send", "Contact")",
                success: function () {
                    alert("Cảm ơn bạn đã liên hệ. Chúng tôi sẽ liên hệ lại bạn trong thời gian sớm nhất.");
                    document.forms[0].reset();
                }
            });
        }

    });
</script>
